/*
 * Joystick.h
 *
 *  Created on: Jan 29, 2010
 *      Author: fmason
 */
#include "../arduinomega/Wire/Wire.h"
#include "../arduinomega/WProgram.h"
#include "../arduinomega/HardwareSerial.h"
#include "ServoMotor.h"

const int MAX_POWER = 1024;
const int FULL_DUTY = 255;
const int HALF_DUTY = 128;
const int OFF_DUTY = 0;

const int FORWARD = 1;
const int BACKWARD = 0;

//Left contact on potentiometer
const int LEFT_JOYSTICK_POWER_PIN = 22;
const int RIGHT_JOYSTICK_POWER_PIN = 23;
const int SERVO_JOYSTICK_POWER_PIN = 24;

//Middle contact on potentiometer
const int LEFT_JOYSTICK_PIN = 0;
const int RIGHT_JOYSTICK_PIN = 1;
const int SERVO_PIN = 2;

//Right contact on potentiometer goes to ground

//const unsigned int MID_POTENTIOMETER_READING = 512;
const unsigned int MID_POTENTIOMETER_READING_LEFT = 584;
const unsigned int MID_POTENTIOMETER_READING_RIGHT = 489;

class Joystick
{
	public:
		unsigned long rightPotentiometerReading;
		unsigned long leftPotentiometerReading;
		unsigned long servoPotentiometerReading;
		//dcMotor dcmotor;
		//RadioTransmitter radiotransmitter;

		uint8_t r_power;
		uint8_t l_power;

		//either direction are either forward, backward or stop
		uint8_t r_direction;
		uint8_t l_direction;

		int turn_magnitude;
		int drive_magnitude;

		void setup();
		void drive();
		void stop();
		int getLeftPower();
		int getRightPower();
		int getServoPosition();
		int getRightDirection();
		int getLeftDirection();
		int getTurn();
		void printMotorInput();
	private:
};

